$(function(){
	var arr={
		hf_s_id:"WD11",
		hf_srv_id:"Pv_jpo_dtl_get",
		hs_action_id:"submit",
		hs_po_id:"HAMPERS",
		hf_locale_id:"en"
	};
	getAjaxRequest(arr,function(result){
		console.log(result)
		if (result.bs_result == BS_RESULT.OK) {
			$('.hampersBox').html('<img src="'+MPJ.apiBase+result.bs_p3_file_id+'" />'+
				'<div class="main">'+
				'<h4>'+result.bs_po_note+'</h4>'+
				'<div class="deadline">Order deadline: <strong>'+result.bs_po_end_dt+'</strong></div>'+
				'<a href="javascript:void(0)" class="terms">Terms & Conditions</a>'+
				'</div>');

			var str='';
			var bvc_pdt = result.bc_group_a_pdt.bvc_pdt;
			if(bvc_pdt.length != 0){
				for (var j = 0; j < bvc_pdt.length; j ++) {
					var product = bvc_pdt[j];
					var isOffer= product.bs_is_offer == "Y" ? '<span><em>offer</em></span>' : '';
					var bs_prom_text=product.bs_prom_text == "" ? "" : product.bs_prom_text;
					str+='<div class="item" data-id="'+product.bj_pdt_id+'" data-item-no="'+product.bs_item_no+'">'+
							'<div class="mainCon">'+
							'<div class="proImg">'+
								'<img src="'+MPJ.apiBase+''+product.bs_simg_file+'" />'+isOffer+
							'</div>'+
							'<div class="mui-media-body">'+
								'<div class="pro-name">'+product.bs_brand+'</div>'+
								'<div class="pro-f-name">'+product.bs_desc+'</div>'+
								'<div class="price">$<em>'+product.bj_rsp+'</div>'+
								'<div class="price-num">'+
									'<span>Qty:</span>'+
									'<div class="mui-numbox" data-numbox-min="1" >'+
										'<button class="mui-btn mui-numbox-btn-minus" type="button">-</button>'+
										'<input class="mui-numbox-input" type="number" value="1" />'+
										'<button class="mui-btn mui-numbox-btn-plus" type="button">+</button>'+
									'</div>'+
									'<a href="javascript:void(0)" class="addCar mui-btn">Add<img src="'+MPJ.base+'/resources/images/icon/main-shopcar.png"></a>'+
								'</div>'+
							'</div>'+
						'</div>'+
						'<div class="descript">'+
							'<img src="'+MPJ.base+'/resources/images/icon/delivery-jt-down.png">'+
							'<p>'+product.bs_po_item_desc_l.substring(0,50)+
							'<span>'+product.bs_po_item_desc_l.substr(51)+'</span></p>'+
						'</div>'+
					'</div>';
				}
			}
			$('.list.horizontal-list').html(str);
			mui('.mui-numbox').numbox();
			//两列数据的列表点击
			$('.list.horizontal-list .item').each(function(){
				var $this=$(this);

                var $img=$(this).find('.descript img');
                var $listBox=$(this).find('.descript p span');
                $img.on('tap',function(){
                    if ($listBox.css('display') == "none") {
                        $listBox.fadeIn();
                        $img.attr('src', MPJ.base+'/resources/images/icon/delivery-jt-up.png');
                    } else {
                        $listBox.fadeOut();
                        $img.attr('src', MPJ.base+'/resources/images/icon/delivery-jt-down.png');
                        mui('#offCanvasContentScroll').scroll().scrollTo(0,0,100);
                    }
                })
				$this.on('tap','.addCar',function(){
					var pdt_id=$this.data('id');
					var item_no=$this.data('item-no');
					var arr={
						hf_s_id:"WD11",
						hf_srv_id:"Av_jcart",
						hs_action_id:"add_all_to_cart",
						hvs_add_pdt_id:pdt_id,
						hvs_add_qty:$this.find('.mui-numbox-input').val(),
					};
					getAjaxRequest(arr,function(result){
						if(result.bs_result==BS_RESULT.OK){
							dialog('Message', 'Add to Shopping Cart', 1);
							var $dialog = $('#dialog');
							$dialog.show();
							$dialog.find('.comfirmBtn').one('click', function() {
								$dialog.hide();
								$dialog.remove();
								getCartSumCount();
							})
						}
					});
				})
			})

		}
	});


})
